package sdfi.lee.test;

	import java.util.Random;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;

import org.apache.activemq.ActiveMQConnectionFactory;
	  
	/** 
	 * 监控ActiveMQ的各种信息Broker,Connection,Queue,Topic的数量和压栈和出栈 
	 * @author longgangbai 
	 * 
	 */  
	public class AC {  
	    
	        protected static final int MESSAGE_COUNT = 2000;  
	        protected static String bindAddress ="tcp://localhost:61616";  
	        //ActiveMQConnectionFactory.DEFAULT_BROKER_BIND_URL;  
	     
	        private static Connection createConnection(final boolean start) throws JMSException {
	            ConnectionFactory cf = new ActiveMQConnectionFactory(bindAddress);
	            Connection conn = cf.createConnection();
	            if (start) {
	                conn.start();
	            }
	            return conn;
	        }
	        public static void main(String[] arg) throws JMSException
	        {
	        	/*	//deleteDestination.action?JMSDestination=q-8335095CB&JMSDestinationType=queue&secret=d4c108e7-4c61-4dfa-9f94-fbf9dba0edb4
	        	 ActiveMQConnection amqConnection = (ActiveMQConnection) createConnection(true);
	             DestinationSource destinationSource = amqConnection.getDestinationSource();
	             
	             Session session = amqConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
	             Topic topic = session.createTopic("TEST.FOO");
	             MessageProducer producer = session.createProducer(topic);
	             MessageConsumer consumer = session.createConsumer(topic);

	             TextMessage msg = session.createTextMessage("Hellow World");
	             producer.send(msg);

	             ActiveMQTopic amqTopic = (ActiveMQTopic)topic;
	             consumer.close();
	             producer.close();
	             session.close();
	            
	             // This line generates a broker error since the consumer is still active.
	             try{
	                 amqConnection.destroyDestination( (ActiveMQDestination)topic );
	             } catch( JMSException expected ) {
	             }
	             amqConnection.close();
			*/
	        	//System.out.println((Math.random()+"").toString().replace(".", "1"));
	        	System.out.println("\n"+"adf"+"\n");
	        	
	        }
	          
	} 

